
#include "ArithmeticMeanFilter.h"

void
ArithmeticMeanFilter::help(std::string &buf) const
{
    buf.append("算术均值滤波器;更适合处理高斯噪声,均匀噪声\n");
    Filter::help(buf);
    return ;
}

double
ArithmeticMeanFilter::operOnNeigh(const cv::Mat &neigh)
{
    unsigned int sum = 0;
    cv::MatConstIterator_<uchar> iter = neigh.begin<uchar>();
    cv::MatConstIterator_<uchar> const end = neigh.end<uchar>();
    for (; iter != end; ++iter) 
        sum += *iter;
    return (double)sum / (neigh.rows * neigh.cols);
}

NOISE_ALGO_REGISTER("ArithmeticMeanFilter",ArithmeticMeanFilter);


